//
//  JDPayingViewController.swift
//  DragonWallet
//
//  Created by volantPig on 2024/12/24.
//

import UIKit

class JDPayingViewController: UIViewController {

    var payingClose:(()->())?
    
    lazy var containerView: UIView = {
        let view = UIView()
        view.makeCorner(8)
        view.backgroundColor = .white
        return view
    }()
    
    lazy var payingImageV: UIImageView = {
        let imageV = UIImageView()
        imageV.image = UIImage(named: "paying")
        return imageV
    }()
    
    lazy var payStateLabel: UILabel = {
        let label = UILabel()
        label.labelConfig(textAlignment: .center, font: UIFont.systemFont(ofSize: 18, weight: .semibold), textColor: color("#333333"), numberOfLines: 1)
        return label
    }()
    
    lazy var backButton: UIButton = {
        let button = UIButton(type: .custom)
        
        button.buttonConfig(normalTitle: "返回", normalTitleColor: .black, titleFont: UIFont.systemFont(ofSize: 16, weight: .regular), backgroundColor: color("#F5F6F8"))
        button.makeCorner(27)
        
        return button
    }()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = .black.withAlphaComponent(0.6)
        
        self.setupUIElements()
        // Do any additional setup after loading the view.
    }
    
    func setupUIElements() {
        self.view.addSubview(self.containerView)
        self.containerView.snp.makeConstraints { make in
            make.centerX.equalTo(self.view)
            make.centerY.equalTo(self.view)
//            make.size.equalTo(CGSize(width: 200, height: 200))
        }
        
        self.containerView.addSubview(self.payingImageV)
        self.payingImageV.snp.makeConstraints { make in
            make.centerX.equalTo(self.containerView)
            make.top.equalTo(self.containerView).offset(24)
            make.size.equalTo(CGSize(width: 132, height: 132))
            make.leading.equalTo(self.containerView).offset(66)
            make.trailing.equalTo(self.containerView).offset(-66)
        }
        
        self.containerView.addSubview(self.payStateLabel)
        self.payStateLabel.snp.makeConstraints { make in
            make.centerX.equalTo(self.containerView)
            make.top.equalTo(self.payingImageV.snp.bottom)
        }
        self.payStateLabel.text = "支付中..."
        self.payStateLabel.sizeToFit()
        
        self.containerView.addSubview(self.backButton)
        self.backButton.snp.makeConstraints { make in
//            make.centerX.equalTo(self.containerView)
            make.top.equalTo(self.payStateLabel.snp.bottom).offset(38)
            make.height.equalTo(54)
            make.trailing.equalTo(self.containerView).offset(-36)
            make.leading.equalTo(self.containerView).offset(36)
            make.bottom.equalTo(self.containerView).offset(-16)
        }
        backButton.addTarget(self, action: #selector(backAction), for: .touchUpInside)
        
    }
    
    @objc func backAction() {
        self.payingClose?()
        self.dismiss(animated: true)
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
